const districts = ["滨湖区"];
const streets = ["蠡湖大道","太湖街道","河埒街道"];
const Community = [["西园里", "隐秀苑", "环湖苑"],
    ["湖山湾家园A区", "湖山湾家园B区","无锡（国家）工业设计园"],
    ["湖滨南苑", "湖滨北苑"]]


// 随机获取
function getRandomData(data: any[]): string {
    let length = data.length
    const index = Math.floor(Math.random() * length);
    return data[index];
}


function getWUXILocation(): string {
    let numb=Math.floor(Math.random() * districts.length);

    return `${districts[numb]}${getRandomData(Community[numb])}${getRandomInt(3, 100)}号`;
}

function getRandomDateTime(): string {
    return (new Date(Date.now()-3600*24*30*5000 - Math.floor(Math.random() * 10000000000))).toISOString().slice(0, 19).replace('T', ' ');
}

function getRandomInt(min: number, max: number): number {
    min = Math.ceil(min); // 向上取整
    max = Math.floor(max); // 向下取整
    return Math.floor(Math.random() * (max - min + 1)) + min;
}


function getLastMonthDates(): string[] {
    const today = new Date();
    const year = today.getFullYear();
    const month = today.getMonth();
    const dates: string[] = [];

    for (let i = 0; i < 30; i++) {
        const date = new Date(year, month, today.getDate() - i);
        const dateStr = `${date.getMonth() + 1}.${date.getDate()}`;
        dates.push(dateStr);
    }
    return dates.reverse(); // 反转数组，使其从最近的日期开始
}

export {getRandomDateTime, getWUXILocation, getRandomInt, getLastMonthDates}